from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from items.canteen import Canteen
from core.support import get_game

class Beach1(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        self.add_item(Canteen())
        
        # build list of actions
        self.add_action(GoBack)
    
    # return description of room.
    def get_description(self):
        return "More beach.  Exciting."
    
    # return image of room
    def get_image(self):
        return 'beach1.jpeg'


class Beach1Handler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Beach1

# define actions for this room

class GoBack(Action):
    def __init__(self):
        Action.__init__(self, "GoBack")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go back"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        game = get_game()
        player = game.get_player()
        if player.death_count > 0:
            return 'startingpoint'
        else:
            return 'death'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    # this method gets called when action executed.  can be overridden in subclass
    def do_action(self,game,room,request):
        player = game.get_player()
        player.death_count -= 1
        return
